package com.rfsp.mcp.service;

import java.util.List;

import com.rfsp.common.service.AreaService;
import com.rfsp.mcp.pojo.sdto.PfmSDTO;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.rfsp.common.base.BaseService;
import com.rfsp.mcp.mapper.PfmMapper;
import com.rfsp.mcp.pojo.po.PfmPO;
import com.rfsp.mcp.pojo.vo.PfmVO;

@Service
public class PfmService extends BaseService<PfmPO> {

    @Autowired
    PfmMapper pfmMapper;

    @Autowired
    AreaService areaCodeService;

    public List<PfmVO> get(PfmSDTO sdto){
        return pfmMapper.query(sdto);
    }

    public List<String> getAllAreaCode(){
    	return pfmMapper.queryAreaCode();
    }

    public List<PfmVO> queryByOrgId(Long orgid){
        return pfmMapper.queryByOrgId(orgid);
    }

    public PfmVO getPfmByAreaCode(String areaCode) {
    	return pfmMapper.getByAreaCode(areaCode);
    }
    
	public PfmVO getById(Long id){
        PfmPO po=pfmMapper.selectByPrimaryKey(id);
        PfmVO vo=new PfmVO();
        BeanUtils.copyProperties(po,vo);
        return vo;
    }
	public void combo(PfmVO vo){
        //地区
        if(StringUtils.isNotBlank(vo.getAreaCode())) {
            vo.setAreaName(areaCodeService.getFullAddress(vo.getAreaCode()));
        }
    }
    public void combo(List<PfmVO> voList){
        for(PfmVO vo:voList ){
            combo(vo);
        }
    }


    public PfmVO findByPayLogId(Long payLogId) {
        return pfmMapper.getByPayLogId(payLogId);
    }
}
